"""
当你copy的文件前面有序号和空格时,使用该方法去掉行数字和空格
然后在文件CTRL + a 后 Ctrl + Alt + l 格式化一下代码. 有一些类方法还可能要手动缩进一下 就ok了
"""

import re
import os


def get_text(path):
    reg = r'^\d{1,3}'
    with open(path, mode='rt', encoding='utf-8') as f:
        for line in f:
            line = line.replace(re.findall(reg, line.lstrip(" "))[0], '')
            with open(path + ".swap", mode='at', encoding='utf-8') as wf:
                wf.write(line)

    os.remove(path)
    os.rename(path + ".swap", path)


get_text(r"G:\项目\FTP项目\client\core\mian.py")
